R/base functions.r

Defines functions every_nth seq_minors

every_nth <- function(x, nth, empty = TRUE, inverse = TRUE) {
  # Source: User Maninal at Stackoverflow 
  if (!inverse) {
    if(empty) {
      x[1:nth == 1] <- ""
      x
    } 
    else {
      x[1:nth != 1]
    }
  } 
  else {
    if(empty) {
      x[1:nth != 1] <- ""
      x
    } 
    else {
      x[1:nth == 1]
    }
  }
}

seq_minors=function(from, to, step, majors) {
  sequence = seq(from, to, step)
  return( every_nth(sequence,majors))
}
Eiriksen/EirikFunctions documentation built on Oct. 30, 2019, 5:31 p.m.